process {
    withName: HMMER_HMMBUILD {
        ext.prefix = { "${meta.id}.ref" }
    }
    withName: HMMER_UNALIGNREF {
        ext.prefix = { "${meta.id}.ref.unaligned" }
        ext.args   = "--gapsym=- afa"
        ext.postprocessing = '| sed "/^>/!s/-//g"'
    }

    withName: HMMER_HMMALIGNREF {
        ext.prefix = { "${meta.id}.ref.hmmalign" }
    }

    withName: HMMER_HMMALIGNQUERY {
        ext.prefix = { "${meta.id}.query.hmmalign" }
    }
    withName: 'HMMER_MASK.*' {
        ext.args   = '--rf-is-mask'
    }

    withName: 'HMMER_MASKQUERY.*' {
        ext.prefix = { "${meta.id}.query.hmmalign" }
    }

    withName: 'HMMER_MASKREF.*' {
        ext.prefix = { "${meta.id}.ref.hmmalign" }
    }

    withName: 'HMMER_AFAFORMATQUERY.*' {
        ext.prefix = { "${meta.id}.query.hmmalign.masked" }
        ext.args   = 'afa'
    }

    withName: 'HMMER_AFAFORMATREF.*' {
        ext.prefix = { "${meta.id}.ref.hmmalign.masked" }
        ext.args   = 'afa'
    }

    withName: 'MAFFT' {
        ext.args = '--keeplength'
    }

    withName: 'EPANG_PLACE' {
        ext.args   = { "--model ${meta.model}" }
    }

    withName: 'GAPPA_GRAFT' {
        ext.prefix = { "${meta.id}.graft" }
    }

    withName: 'GAPPA_ASSIGN' {
        ext.prefix = { "${meta.id}.taxonomy" }
        ext.args   = "--per-query-results --krona --sativa"
        ext.when   = { taxonomy }
    }

    withName: 'GAPPA_HEATTREE' {
        ext.prefix = { "${meta.id}.heattree" }
        ext.args = "--write-nexus-tree --write-phyloxml-tree --write-svg-tree"
    }
}
